package com.aiguigu.gulimall.product.controller;

import com.aiguigu.gulimall.product.server.WebSocketSever;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author
 * @date 2022/10/24
 * websocket接口
 */
@RestController
@RequestMapping(value = "/websocket")
public class WebSocketController {
    @Autowired
    private WebSocketSever webSocketServer;

    /**
     * 模拟数据发送
     */
//    @ApiOperation(value = "模拟数据发送", notes = "模拟数据发送")
//    @ApiImplicitParams({
//            @ApiImplicitParam(paramType = "query", name = "message", value = "模拟消息", required = true, dataType = "String"),
//    })
    @GetMapping(value = "/sendTestMessage")
    public boolean sendTestMessage(String message) {
//        AjaxJson ajaxJson = new AjaxJson();
        try {
            WebSocketSever.sendAllMessage(message);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }
}
